<include file="Common/header" />
<title>栏目设置</title>
</head>
<body>
<div class="pd-20">
	<form action="" method="post" class="form form-horizontal" id="form-category-add">
		<div id="tab-category" class="HuiTab">
			<div class="tabBar cl">
				<span>基本设置</span><!--
				<span>模版设置</span>
				<span>SEO</span>-->
			</div>
			<div class="tabCon">
				<input type="hidden" name="menu_id" id="menu_id" value="{$info['menu_id']}" />
				<div class="row cl">
					<label class="form-label col-3"><span class="c-red">*</span>上级栏目：</label>
					<div class="formControls col-6"> 
						<span class="select-box">
							<select class="select" id="sel_Sub" name="sel_Sub" >
								<option value="0">顶级分类</option>
								<?php foreach($menulist as $ls){ ?>
								<option value="{$ls['menu_id']}" <?php echo $ls['menu_id'] == $info['parent_id'] ? 'selected' : ''; ?>>&nbsp;&nbsp;├&nbsp;{$ls['menu_name']}</option>
								<?php } ?>
							</select>
						</span> 
					</div>
					<div class="col-3"> </div>
				</div>
				<div class="row cl">
					<label class="form-label col-3"><span class="c-red">*</span>菜单名称：</label>
					<div class="formControls col-6">
						<input type="text" class="input-text" value="{$info['menu_name']}" placeholder="" id="menu_name" name="menu_name" datatype="*2-16" nullmsg="用户名不能为空">
					</div>
					<div class="col-3 menu_name"> </div>
				</div>
				<div class="row cl">
					<label class="form-label col-3">图标样式：</label>
					<div class="formControls col-6">
						<input type="text" class="input-text" value="{$info['icon']}" placeholder="" id="menu_icon" name="menu_icon">
					</div>
					<div class="col-3 menu_icon"> </div>
				</div>
				<div class="row cl">
					<label class="form-label col-3">链接地址：</label>
					<div class="formControls col-6">
						<input type="text" class="input-text" value="{$info['action']}" placeholder="" id="menu_url" name="menu_url">
					</div>
					<div class="col-3 menu_url"> </div>
				</div>
				<div class="row cl">
					<label class="form-label col-3">排序：</label>
					<div class="formControls col-6">
						<input type="text" class="input-text" value="{$info['sort']}" placeholder="" id="sort" name="sort">
					</div>
					<div class="col-3 menu_url"> </div>
				</div>
			</div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-3">
				<input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</div>
</div>

<script type="text/javascript">
$(function(){
	//渲染界面
	$.Huitab("#tab-category .tabBar span","#tab-category .tabCon","current","click","0");
	//验证参数
	$(".radius").on('click', function(){
		var data = {};
			data.parent_id = $("#sel_Sub").val();
		var menu_name = $("#menu_name").val();
		if(menu_name.length < 3){
			$(".menu_name").html('菜单名称长度小于3个字符');
			return false;
		}else{
			$(".menu_name").html('');
			data.rolename = menu_name;
		}
		
		data.menu_icon = $("#menu_icon").val();
		data.action = $("#menu_url").val();
		data.sort = $("#sort").val() || 0;
		data.menu_id = $("#menu_id").val() || 0;
		
		$.post('add.html', data, function(row){
			if(row/1){
				layer.msg('编辑成功', {icon:1,time:1000});
				setTimeout(function(){
					window.parent.location.reload(); //刷新
					var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
				}, 1000);
			}else{
				layer.msg('编辑失败', {icon: 0, time: 1000}); 
			}
		});
	});
});
</script>
</body>
</html>